﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    x:Class="DDU.Curriculum.Views.PreferenceView"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False" >

    <phone:PhoneApplicationPage.Resources>
        <Converters:BufferLengthConverter x:Key="BufferLengthConverter"/>
        <Converters:CultureNameToNativeNameConverter x:Key="CultureNameToNativeNameConverter" />
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:PreferenceViewModel/>
        </Grid.DataContext>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_PREFERENCE_TITLE}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ScrollViewer>
                <StackPanel>
                    <toolkit:ListPicker Header="{StaticResource IDS_PREFERENCE_DISPLAYNAME}" 
                                        ItemsSource="{Binding Path=SupportLanguages}" 
                                        SelectedItem="{Binding GlobalSettings.Language, Mode=TwoWay}">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource CultureNameToNativeNameConverter}}" />
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource CultureNameToNativeNameConverter}}" 
                                           Style="{StaticResource PhoneTextTitle2Style}"
                                           Margin="0,12"/>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                    </toolkit:ListPicker>

                    <UX:UXTextMenu Content="{StaticResource IDS_PREFERENCE_MANAGE_LANGUAGE_PACKAGES}" Margin="0,0,0,12"/>

                    <toolkit:ToggleSwitch Header="{StaticResource IDS_PREFERENCE_SHOW_ALL_ACTIVITIES}" 
                                          IsChecked="{Binding Path=GlobalSettings.ShowAllActivities, Mode=TwoWay}" />
                    <toolkit:ToggleSwitch Header="{StaticResource IDS_PREFERENCE_SHOW_ALL_VACATIONS}" 
                                          IsChecked="{Binding Path=GlobalSettings.ShowAllVacations, Mode=TwoWay}" />

                    <UX:UXTextMenu Content="{StaticResource IDS_PREFERENCE_UNLOCL_ADVANCED_FEATURES}" 
                                   Margin="0,0,0,12" 
                                   Visibility="{Binding Path=ShowUnlockButton, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                   Uri="/Views/UnlockView.xaml" />
                </StackPanel>
            </ScrollViewer>
            <StackPanel Grid.Row="1" Margin="0,12">
                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                           Text="{StaticResource IDS_PREFERENCE_DOWNLOADED_DATA_LENGTH}"/>
                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}"
    				Foreground="{StaticResource PhoneChromeBrush}" >
                    <Run Text="{StaticResource IDS_PREFERENCE_NETWORK_DATA_CELL}"/>
                    <Run Text="{Binding GlobalSettings.CellNetworkDataLength, Converter={StaticResource BufferLengthConverter}}"/>
                    <Run Text=" "/>
                    <Run Text="{StaticResource IDS_PREFERENCE_NETWORK_DATA_WIFI}"/>
                    <Run Text="{Binding GlobalSettings.WiFiNetworkDataLength, Converter={StaticResource BufferLengthConverter}}"/>
                </TextBlock>

            </StackPanel>
            
            <Grid Grid.Row="2" Margin="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <UX:UXIconTextButton Margin="12" 
                                     HorizontalAlignment="Center" 
                                     Content="{StaticResource IDS_PREFERENCE_CLEAN_COVERS}" 
                                     Path="{StaticResource PATH_ICON_CLEAN}" 
                                     Command="{Binding CleanBookCoverCommand}" />

                <UX:UXIconTextButton Margin="12" Grid.Column="1"
                                     HorizontalAlignment="Center" 
                                     Content="{StaticResource IDS_PREFERENCE_MAKE_NETWORK_DATA_ZERO}" 
                                     Path="{StaticResource PATH_ICON_UNDO}" 
                                     Command="{Binding MakeZeroCommand}" />
            </Grid>
            
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
